package com.game.business.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;

import com.game.common.annotation.Log;
import com.game.common.core.controller.BaseController;
import com.game.common.core.domain.AjaxResult;
import com.game.common.enums.BusinessType;
import com.game.common.utils.poi.ExcelUtil;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.game.business.domain.TGameRw;
import com.game.business.service.ITGameRwService;
import com.game.common.core.page.TableDataInfo;

/**
 * 任务类型Controller
 *
 * @author ruoyi
 * @date 2025-10-09
 */
@RestController
@RequestMapping("/business/gamerw")
public class TGameRwController extends BaseController {
    @Autowired
    private ITGameRwService tGameRwService;

/**
 * 查询任务类型列表
 */
//@RequiresPermissions("business:gamerw:list")
@GetMapping("/list")
    public TableDataInfo list(TGameRw tGameRw) {
        startPage();
        List<TGameRw> list = tGameRwService.selectTGameRwList(tGameRw);
        return getDataTable(list);
    }

    /**
     * 导出任务类型列表
     */
    //@RequiresPermissions("business:gamerw:export")
    @Log(title = "任务类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TGameRw tGameRw) {
        List<TGameRw> list = tGameRwService.selectTGameRwList(tGameRw);
        ExcelUtil<TGameRw> util = new ExcelUtil<TGameRw>(TGameRw. class);
        util.exportExcel(response, list, "任务类型数据");
    }

    /**
     * 获取任务类型详细信息
     */
    //@RequiresPermissions("business:gamerw:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(tGameRwService.getById(id));
    }

    /**
     * 新增任务类型
     */
    //@RequiresPermissions("business:gamerw:add")
    @Log(title = "任务类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TGameRw tGameRw) {
        return toAjax(tGameRwService.save(tGameRw));
    }

    /**
     * 修改任务类型
     */
    //@RequiresPermissions("business:gamerw:edit")
    @Log(title = "任务类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TGameRw tGameRw) {
        return toAjax(tGameRwService.updateById(tGameRw));
    }

    /**
     * 删除任务类型
     */
    //@RequiresPermissions("business:gamerw:remove")
    @Log(title = "任务类型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tGameRwService.removeByIds(Arrays.asList(ids)));
    }
}
